import Vue from 'vue';
import ElementUI from 'element-ui';
import axios from 'axios';
import VCharts from 'v-charts';
import router from './router';
import store from './store';
import 'element-ui/lib/theme-chalk/index.css';
import './assets/css/common.less';
import './assets/css/columns.css';
import 'font-awesome/css/font-awesome.min.css';
import './assets/font/iconfont.css';
import Ue from './components';
import App from './App.vue';
import './lib/echarts/china';
import 'quill/dist/quill.core.css';
import 'quill/dist/quill.bubble.css';
import 'quill/dist/quill.snow.css';

import mavonEditor from 'mavon-editor';
import 'mavon-editor/dist/css/index.css';

Vue.use(Ue);
Vue.use(ElementUI, {size: 'mini'});
Vue.use(VCharts);
Vue.use(mavonEditor);

let vue = new Vue({
  router,
  store,
  render: h => h(App)
});
vue.$mount('#app');

axios.interceptors.response.use(function (response) {
  return response;
}, function (error) {
  if (error.response.status === 401) {
    router.push('/login');
    console.error('session失效，请重新登录');
  } else {
    /* 请求错误时做些事 */
    vue.$message.error('系统出错，请联系管理员');
    return Promise.reject(error);
  }
});
